<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 引入vue2的js文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.9/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- <input id="inputId" type="text" /> <br /> -->
      <input ref="inputRef" type="text" /> <br />
      <br />
      <br />
      <button @click="focus">聚焦</button>
    </div>

    <!-- 逻辑部分 -->
    <script>
      new Vue({
        el: '#app',
        methods: {
          focus() {
            // document.getElementById('inputId').focus()
            // console.log('---focus---')
            // console.log(this.$refs.inputRef)
            this.$refs.inputRef.focus()
          }
        }
      })
    </script>
  </body>
</html>
